package com.supor.aiot.food.view;

import android.content.Context;
import android.graphics.Rect;
import android.util.Log;
import android.view.View;

import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;

import com.supor.aiot.food.R;

public class GrideDecoration extends RecyclerView.ItemDecoration {

    private Context mContext;
    private int bottomBoard = 0;
    private int headBoard = 0;

    public GrideDecoration(Context mContext) {
        this.mContext = mContext;
    }

    public GrideDecoration(Context mContext,int bottom) {
        this.mContext = mContext;
        this.bottomBoard = bottom;
    }

    public GrideDecoration(Context mContext,int head,int bottom) {
        this.mContext = mContext;
        this.bottomBoard = bottom;
        this.headBoard = head;
    }

    @Override
    public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
        if (bottomBoard==0){
            outRect.top = mContext.getResources().getDimensionPixelSize(R.dimen.dp_0);
        }else {
            outRect.top = headBoard;
        }
        if (bottomBoard==0){
            outRect.bottom = mContext.getResources().getDimensionPixelSize(R.dimen.dp_2);
        }else {
            outRect.bottom = bottomBoard;
        }
    }
}
